package com.wanmei.service;


import com.wanmei.mapper.ProductMapper;
import com.wanmei.mapper.TransportMapper;
import com.wanmei.pojo.Product;
import com.wanmei.pojo.Transport;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


@Service("TransportService")
public class TransportService {
    @Autowired
    private TransportMapper transportMapper;
    @Autowired
    private ProductMapper productMapper;


    /**
     * 获取到运费
     * @param pid
     * @param fromAddress
     * @param toAddress
     * @return
     */
    public Double getTransportMoney(int pid,String fromAddress,String toAddress){
        Product product = productMapper.selectByPrimaryKey(pid);
        return transportMapper.getMoneyByCidAndAdress(product.getCid(),fromAddress,toAddress);
    }

//    /**
//     * 点击产品界面的时候获取默认送货地的值
//     */
//    public Transport getDefaultTrans(int pid){
//        Transport transport = new Transport();
//        Product product = productMapper.getProductAll(pid);
//        String  DefaultFromName = transportMapper.getDefaultFromAddress(product.getCid());
//        transport.setFromAddress(DefaultFromName);
//        transport.setMoney(0.00);
//        return  transport;
//    }
//    public List<String> getDefaulTransport(int pid){
//        Product product = productMapper.getProductAll(pid);
//        List<String> list = transportMapper.getFromAddressByCid(product.getCid());
//        return list;
//    }

//    /**
//     * 获取送货地址的所有下拉框
//     * @param cid
//     * @return
//     */
//    public List<String> getFromAdress(int cid){
//        return transportMapper.getFromAddressByCid(cid);
//    }

//    /**
//     * 获取收获地址下拉框还有需要的运费
//     * @param cid
//     * @param fromAddress
//     * @return
//     */
//    public List<Transport> getTransToAddressAndMoney(int cid, String fromAddress){
//        return transportMapper.getTransToAddressAndMoney(cid,fromAddress);
//    }
}
